﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _7._1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        Student[] stu = new Student[100];
        public void Display(Student stu)
        {
            string type = "";
            if(stu is CollegeStu)
            {
                type = "大学生";
            }
            else if (stu is MiddleStu)
            {
                type = "中学生";
            }
            else
            {
                type = "小学生";
            }
            lblshow.Text += string.Format("总人数：{0},姓名：{1},年龄:{2},{3},平均成绩为：{4}\n", Student.count, stu.StuName, stu.StuAge, type, stu.GetAverage());

        }
        private void txtname_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            Pupil pl = new Pupil(txtname.Text, Convert.ToInt32(txtage.Text), Convert.ToDouble(txtchinese.Text), Convert.ToDouble(txtmaths.Text));
            Display(pl);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            MiddleStu mds = new MiddleStu(txtname.Text, Convert.ToInt32(txtage.Text), Convert.ToDouble(txtchinese.Text), Convert.ToDouble(txtmaths.Text), Convert.ToDouble(txtEnglish.Text));
            Display(mds);
        }

        private void button3_Click(object sender, EventArgs e)
        {
            CollegeStu cls = new CollegeStu(txtname.Text, Convert.ToInt32(txtage.Text), Convert.ToDouble(txtchinese.Text), Convert.ToDouble(txtmaths.Text), Convert.ToDouble(txtEnglish.Text));
            Display(cls);
        }
    }
   
    
    
   
}
